home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-16 | 3.4 KB | 122 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CCrossMemory.h ©1996-97 Timo Eloranta All rights reserved.
- // ===========================================================================
- // This class, used by CGraphDrawing, was added to the application in the
- // optimization phase to speed up the process of calculating edge crossings.
-
- #pragma once
-
- #include <PP_Types.h>
-
- class CCrossMemory
- {
- private:
- UInt32 mEdgeCount; // Nbr of edges
- UInt16 mCrossTotal; // Nbr of edge crossings
-
- Boolean *mArray; // Storage of crossing facts (bool)
- Boolean *mIterator; // Storage scanner
-
- UInt32 mSize; // Size of the storage (columns)
- UInt32 mByteSize; // Size of the storage (in bytes)
-
- public:
- CCrossMemory( UInt16 inEdgeCount );
- ~CCrossMemory();
-
- CCrossMemory &operator=( const CCrossMemory & inCM );
-
- void ResetCrossTotal()
- { mCrossTotal = 0; };
- Int32 GetCrossTotal() const
- { return (Int32) mCrossTotal; };
-
- void ResetScanner()
- { mIterator = mArray; };
- void AdvanceScanner()
- { mIterator++; };
-
- void SetCrossFact( Boolean inCrosses );
- void SetCrossFactByFlipping( Boolean inCrosses );
-
- Boolean HasStorage() const
- { return mArray != nil; };
- };
-
- // ===========================================================================
- // • Inline Functions
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • operator=
- //
- // Called by: CGraphDrawing::RuntimeCopy
- // ---------------------------------------------------------------------------
-
- inline CCrossMemory &
- CCrossMemory::operator=( const CCrossMemory & inCM )
- {
- mEdgeCount = inCM.mEdgeCount;
- mCrossTotal = inCM.mCrossTotal;
-
- ::BlockMoveData( inCM.mArray, mArray, mByteSize );
-
- return *this;
- }
-
- // ---------------------------------------------------------------------------
- // • SetCrossFact
- //
- // Called by: CGraphDrawing::SmarterCountSect
- // ---------------------------------------------------------------------------
-
- inline void
- CCrossMemory::SetCrossFact(
- Boolean inCrosses )
- {
- *mIterator = inCrosses;
- if ( inCrosses )
- mCrossTotal++;
- }
-
- // ---------------------------------------------------------------------------
- // • SetCrossFactByFlipping
- //
- // Called by: CGraphDrawing::SmarterCountSect
- // ---------------------------------------------------------------------------
-
- inline void
- CCrossMemory::SetCrossFactByFlipping(
- Boolean inCrosses )
- {
- if ( *mIterator ) { // These edges used to cross...
- if ( !inCrosses ) { // ...but don't cross anymore
- *mIterator = 0;
- mCrossTotal--; // Decrease cross count by 1
- }
- }
- else // These edges didn't cross before...
- if ( inCrosses ) { // ... but do now
- *mIterator = 1;
- mCrossTotal++; // Increase cross count by 1
- }
- }
-
- // ---------------------------------------------------------------------------
- // • GetBoolPtr ( NOT USED BY THIS VERSION )
- // ---------------------------------------------------------------------------
- // The returned pointer points to the boolean, which tells whether
- // the two edges (inEdgeN1 & inEdgeN2) currently intersect.
-
- /*
- inline Boolean *
- CCrossMemory::GetBoolPtr(
- UInt16 inEdgeN1,
- UInt16 inEdgeN2 ) const
- {
- return mArray +
- ((( (inEdgeN1 - 1) * (2 * mEdgeCount - inEdgeN1) ) / 2 )
- + inEdgeN2 - inEdgeN1 - 1 );
- }
- */
-